package hesso.smartdraw.ch.guielements;

import hesso.smartdraw.ch.DrawWallScreen;
import hesso.smartdraw.ch.model.Color;

import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.input.touch.TouchEvent;
import org.anddev.andengine.opengl.texture.region.TextureRegion;

import android.util.Log;

public class Level extends Sprite {
	
	private Color color;
	private DrawWallScreen dw;
	
	private int destLevel;
	
	public Level(float pX, float pY, TextureRegion texture, int destLevel, DrawWallScreen dw, boolean active) {
		super(pX, pY, texture);
		this.destLevel = destLevel;
		this.dw = dw;
    	if(active) {
    		setColor(Color.RED);
    	} else {
    		setColor(Color.WHITE);
    	}
	}

	
	public void setColor(Color c) {
		this.color = c;
		super.setColor(c.getRed(), c.getGreen(), c.getBlue());
	}
	
	@Override
    public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
            switch(pSceneTouchEvent.getAction()) {
                    case TouchEvent.ACTION_DOWN:
                    		Log.d("PHIPPI", "Load Level :"+destLevel);
                    		dw.changeLevel(destLevel);
                            break;
                    case TouchEvent.ACTION_MOVE:
                            break;
                    case TouchEvent.ACTION_UP:                
                            break;
            }
            return true;
    }

	public DrawWallScreen getDw() {
		return dw;
	}


	public void setDw(DrawWallScreen dw) {
		this.dw = dw;
	}
	
	

}
